/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cip.esymons.eventos.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.eventos.be.Preevento;
import org.cip.esymons.eventos.be.TarifarioEvento;

/**
 *
 * @author oscar
 */
public class TarifarioEventoDelegate {

    TarifarioEventoFacadeLocal local;

    public TarifarioEventoDelegate() {
        local = lookupTarifarioEventoFacade();
    }

    public void actualizar(TarifarioEvento taf) {
        local.edit(taf);
    }

    public List<TarifarioEvento> listarPorPreEvento(Preevento preEventoSeleccionado) throws Exception {
        return local.tarifariosPorEvento(preEventoSeleccionado);
    }

    private TarifarioEventoFacadeLocal lookupTarifarioEventoFacade() {
        try {
            Context c = new InitialContext();
            return (TarifarioEventoFacadeLocal) c.lookup("java:comp/env/TarifarioEventoFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public void registrar(TarifarioEvento tarifa) throws Exception {
        local.create(tarifa);
    }
}
